package com.beimihu.leetcode;


//https://leetcode.cn/problems/valid-anagram/?envType=study-plan-v2&envId=top-interview-150
public class IsAnagram {
    public boolean isAnagram(String s, String t) {
        if(s.length() != t.length()){
            return false;
        }
        int[] cnt = new int[26];

        for (int i = 0 ; i< s.length(); i++){
            cnt[s.charAt(i) - 'a'] ++;
        }
        for(int i = 0; i <t.length();i++){
            cnt[t.charAt(i) - 'a'] --;
            if(cnt[t.charAt(i) - 'a'] < 0){
                return false;
            }
        }
        return true;
    }
}
